//
//  HealthViewCell.m
//  SHHCPhone
//
//  Created by sheng long on 14-7-1.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "HealthViewCell.h"
#import "UIImageView+WebCache.h"

@interface HealthViewCell()
{
    UIImageView *headImageView;
    UILabel *titleLabel;
    UILabel *timeLabel;
}
@end

@implementation HealthViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier size:(CGSize)size
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 185)];
        [bgView setCenter:CGPointMake(size.width/2, 10+bgView.frame.size.height/2)];
        [self.contentView addSubview:bgView];
        bgView.layer.borderWidth = .5;
        bgView.layer.borderColor = GET_COLOR(@"dddddd").CGColor;
        
        headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 560/2, 290/2)];
        [headImageView setBackgroundColor:NORMAL_IMAGE_BGCOLOR];
        [bgView addSubview:headImageView];
        
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(6, headImageView.frame.size.height+headImageView.frame.origin.y+6, size.width-6*2, 14)];
        [titleLabel setTextColor:GET_COLOR(@"3e3e3e")];
        [titleLabel setBackgroundColor:[UIColor clearColor]];
        [titleLabel setFont:[UIFont systemFontOfSize:13]];
        [bgView addSubview:titleLabel];
        
        timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.frame.origin.x, titleLabel.frame.size.height+titleLabel.frame.origin.y+2, titleLabel.frame.size.width, 11)];
        [timeLabel setTextColor:GET_COLOR(@"bbbbbb")];
        [timeLabel setBackgroundColor:[UIColor clearColor]];
        [timeLabel setFont:[UIFont systemFontOfSize:10]];
        [bgView addSubview:timeLabel];
    }
    return self;
}

-(void)setContent:(HealthViewInfo*)info
{
//    NSString *imageUrl = [NSString stringWithFormat:@"%@!300x150",[info.pic valueForKey:@"url"]];
//    CLog(@"%@===%@",imageUrl,[info.pic valueForKey:@"url"]);
//    [headImageView setImageWithURL:[NSURL URLWithString:imageUrl]];

    [headImageView setImageWithURL:[NSURL URLWithString:[info.pic valueForKey:@"url"]] placeholderImage:[UIImage imageNamed:@"默认图片icon.png"]];
//    [headImageView setImage:[UIImage imageNamed:@"默认图片icon.png"]];
//    [headImageView setImageWithURL:[NSURL URLWithString:[info.pic valueForKey:@"url"]]];
    
    [titleLabel setText:info.title];
    [timeLabel setText:info.pubtime];
    
//    [headImageView setBackgroundColor:[UIColor blackColor]];
//    [titleLabel setText:@"标题名称标题名称"];
//    [timeLabel setText:@"2014-03-21"];
}

@end
